from Animal import Animal
class Student():
    def __init__(self,name,age,sno):
        self.name = name
        self.age = age
        self.sno = sno

    def __str__(self):
        return f"姓名为：{self.name},年龄为{self.age},学号为{self.sno}"
    """
    eq判断两个对象是否相等
    1、判断两个对象是不是同一个类型，不是直接返回False
    2、如果两个对象是同一个类型，再继续判断数据是否一致
    """
    def __eq__(self,other):
        # 1、判断other是不是Student类型
        if isinstance(other,Student):
            return self.sno == other.sno
        else:
            print("两个对象不是同一个类，不具备比较性")
            return False

    def __gt__(self,other):
        if isinstance(other, Student):
            return self.age>other.age
        else:
            raise Exception("两个对象不是同一个类型，不具备比较性")
    def run(self):
        pass

    def __len__(self):
        return len(self.name)

cl = Student("曹磊类",20,"s001")
cl1 = Student("曹磊",19,"s001")
dog = Animal("阿黄",1)
# print(cl > dog)
print(len(cl))

